//
//  HYTalkTableViewCell.m
//  MusicMV
//
//  Created by Eternity on 16/3/20.
//  Copyright © 2016年 Eternity. All rights reserved.
//

#import "HYTalkTableViewCell.h"

@interface HYTalkTableViewCell ()

@property (nonatomic , strong) UILabel *userNameLabel;
@property (nonatomic , strong) UIImageView *userHeadImg;
@property (nonatomic , strong) UILabel *contentLabel;
@property (nonatomic , strong) UILabel *dateCreated;


@end




@implementation HYTalkTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self Create];
    }
    return self;
}

- (void)Create{
    self.userHeadImg = [[UIImageView alloc] init];
    [self.contentView addSubview:_userHeadImg];
    self.userNameLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_userNameLabel];
    self.contentLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_contentLabel];
    self.dateCreated = [[UILabel alloc] init];
    [self.contentView addSubview:_dateCreated];

}

- (void)layoutSubviews {
    [super layoutSubviews];
    _userHeadImg.frame = CGRectMake(10 * wt, 5 * ht, 20 * wt, 20 * ht);
    _userHeadImg.layer.cornerRadius = 10;
    _userHeadImg.backgroundColor = [UIColor clearColor];
    _userNameLabel.frame = CGRectMake(35 * wt, 5 * ht, SCREEN_WIDTH - 40 * wt, 20 * ht);
    _userNameLabel.textColor = RGBA(0, 210, 190, 1);
    _userNameLabel.font = [UIFont systemFontOfSize:14];
    _userNameLabel.backgroundColor = [UIColor clearColor];
    CGSize size = [XRAFNetworkTool labelRectWithSize:CGSizeMake(SCREEN_WIDTH - 20 * wt, 0) LabelText:_talkModel.content Font:[UIFont systemFontOfSize:17]];
    _contentLabel.numberOfLines = 0;
    _contentLabel.frame = CGRectMake(10 * wt, 35 * ht, SCREEN_WIDTH - 20 * wt, size.height);
    _contentLabel.textColor = [UIColor whiteColor];
    _contentLabel.backgroundColor = [UIColor clearColor];
    _dateCreated.frame = CGRectMake(10 * wt, _contentLabel.frame.origin.y + _contentLabel.frame.size.height + 10 * ht, SCREEN_WIDTH, 20);
    _dateCreated.backgroundColor = [UIColor clearColor];
    _dateCreated.textColor = [UIColor cyanColor];
    _dateCreated.font = [UIFont systemFontOfSize:11];
    
}

- (void)setTalkModel:(HYTalkModel *)talkModel {
    
    _talkModel = talkModel;
    [_userHeadImg sd_setImageWithURL:[NSURL URLWithString:_talkModel.userHeadImg]];
    _userNameLabel.text = _talkModel.userName;
    _contentLabel.text = _talkModel.content;
    _dateCreated.text = _talkModel.dateCreated;

}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
